<%@ page language="java" import="java.util.Map,com.ruohi.util.common.CommonDate" pageEncoding="UTF-8" %><%
	Map adminInfo = (Map)session.getAttribute("adminInfo");
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
  <head>
    <title>欢迎登录</title>
    <link href="/plugin/ui/ligerUI/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
	<link href="/backend/style/style.css" rel="stylesheet" type="text/css" />
	<script src="/plugin/jquery/jquery.min.js" type="text/javascript"></script>
	<script src="/plugin/ui/ligerUI/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
  </head>
  
  <body style="margin: 0;padding: 0;">
	<div class="welcome">
		<div class="toolbar">
			<span style="font-size: 14px; margin: 5px 0 0 5px;">您可以在此自定义自己的常用工作内容！</span>
		</div>
		<div class="toolbar" style="float: right; margin-right: 45px;">
			<input style="margin-right: 10px;" class="btn" type="button" value="添加分类" onclick="addCategory();" />
			<input class="btn" type="button" value="添加标签" onclick="addLink();" />
		</div>
		<div style="clear: left;"></div>
		<div class="category" id="sortable"></div>
	</div>
  </body>
</html>
<script src="/backend/scripts/common.js" type="text/javascript"></script>
<script src="/plugin/ui/jqueryUI/jquery-ui-1.8.20.custom.min.js"></script>
<script type="text/javascript">
function getMyCategory(){
	jQuery(".category").html("");
	jQuery.ajax({
		url : '/backend/action/ajax_r.jsp',
		data : { flag : 'getAddWorkCategory' } ,
		type : 'post' ,
		async : false ,
		success : function(data){
			var arr = eval(data);
			for(var i=0;i<arr.length;i++){
				createOneCategory(arr[i]);
			}
			parent.jQuery.ligerDialog.closeWaitting();
		}
	});
}
function doEdit(id){
	jrWindow("/backend/service.21-sun.com/service_work_category/service_work_category_edit.jsp?id="+id,"编辑类别",400,80);
}
function doDel(id){
	jrConfirm("确认删除该类别及该类别下的所有工作内容吗？",function(rs){
		if(rs){
			parent.jQuery.ligerDialog.waitting("<img src='/backend/images/loading.gif' width='20' height='20' /><span style='position: relative; left:10px; top:-4px;'>删除中，请稍后...</span>");
			jQuery.ajax({
				url : '/backend/action/ajax_cud.jsp',
				data : { flag : 'deleteWorkCategory' , id : id },
				async : false ,
				success : function(){
					getMyCategory();
				}
			});
		}
	});
}
getMyCategory();
function createOneCategory(json){
	var htm = '<div class="sub" id="'+json.uuid+'">';
	htm += '<div class="ctitle"><div class="cname">'+json.name+'</div><div class="cbar"><a href="javascript:void(0);" onclick="doEdit(\''+json.uuid+'\');">编辑</a>-<a href="javascript:void(0);" onclick="doDel(\''+json.uuid+'\');">删除</a></div><div style="clear:left;"></div></div>';
	htm += '<ul class="cintro">';
	if(typeof(json.list)!='undefined'){
		var _target = "";
		var obj;
		for(var i=0;i<json.list.length;i++){
			obj = json.list[i];
			_target = obj.link_target;
			htm += '<li class="csub">';
			htm += '<div class="csubname">';
			//如果是本站
			if(_target=='109002'){
				htm += '<a href="javascript:void(0);" onclick="parent.f_addTab(\''+obj.uuid+'\',\''+obj.name+'\',\''+obj.link+'\');">'+obj.name+'</a>';
			}else{
				htm += '<a href="'+obj.link+'" target="_blank">'+obj.name+'</a>';
			}
			htm += '</div>';
			htm += '<div class="csubbar"><a href="javascript:void(0);" onclick="doSubEdit(\''+obj.uuid+'\');">编辑</a>-<a href="javascript:void(0);" onclick="doSubDel(\''+obj.uuid+'\');">删除</a></div>';
			htm += '<div style="clear:left;"></div>';
			htm += '</li>';
		}
	}
	htm += '</ul>';
	htm += '<div class="cbottom"><a href="javascript:void(0);" onclick="addLink(\''+json.uuid+'\');">添加</a></div>';
	htm += '</div>';
	jQuery(".category").prepend(htm);
	jQuery(".welcome .category .sub .ctitle").hover(function(){
		jQuery(this).find(".cbar").show();
	},function(){
		jQuery(this).find(".cbar").hide();
	});
	jQuery(".welcome .category .sub .csub").hover(function(){
		jQuery(this).find(".csubbar").show();
	},function(){
		jQuery(this).find(".csubbar").hide();
	});
	jQuery("#sortable").sortable({
		stop : function(event, ui) {
			doSort();
		}
	});
}
function doSort(){
	var ids = '';
	jQuery.each(jQuery(".sub"),function(index,data){
		ids += jQuery(this).attr("id")+",";
	});
	ids = ids.substring(0,ids.length-1);
	jQuery.post("/backend/action/ajax_cud.jsp",{
		flag : 'sortWork' , 
		ids : ids
	});
}
//添加分类
function addCategory(){
	jQuery.post("/backend/action/ajax_cud.jsp",{
		flag : 'addWorkCategory'
	},function(data){
		createOneCategory({
			uuid : data ,
			name : '默认分类'
		});
	})
}
function addLink(cateid){
	jrWindow("/backend/service.21-sun.com/service_work/service_work_edit.jsp?category_uuid="+cateid,"添加标签",650,200);
}
function doSubEdit(id){
	jrWindow("/backend/service.21-sun.com/service_work/service_work_edit.jsp?id="+id,"编辑标签",650,200);
}
function doSubDel(id){
	jrConfirm("确认删除该工作标签吗？",function(rs){
		if(rs){
			parent.jQuery.ligerDialog.waitting("<img src='/backend/images/loading.gif' width='20' height='20' /><span style='position: relative; left:10px; top:-4px;'>删除中，请稍后...</span>");
			jQuery.ajax({
				url : '/backend/action/ajax_cud.jsp',
				data : { flag : 'deleteWork' , id : id },
				async : false ,
				success : function(){
					getMyCategory();
				}
			});
		}
	});
}
</script>